<!DOCTYPE html> 
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SELECTOUT</title> 
<style>
#header {
	background-color:black;
	color:white;
	text-align:center;
    padding:1px;}
#foot {
	background-color:black;
	color:white;
	text-align:center;
    padding:20px;
	clear:both;
}
.city {
	background-color:yellow;
    float: left;
    margin: 5px;
    padding: 15px;
    width: 384px;
    height: 280px;
    border: 2px solid black;
	text-align:center;
}
#body {
	background-color:yellow;
	color:black;
	text-align:center;
	height:305px;
	width:1300px;
	float:left;
} 
</style>
</head>	
<body>
<div id="header"><h1>搜索结果</h1></div>
<?php
header('Content-type:text/html;charset=utf-8');
include_once("../class/mysqlclass.php");
session_start();
$_SESSION['act']='select';
$mysqli = new writing;
$mysqli = $mysqli -> Con();
//判断哪种搜索形式
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	if($_GET['act']=='acs'){
	$tle = Addslashes($_POST['stl']);
	$sql = "select * from `write` where title= '{$tle}'";}
	if($_GET['act']=='stt'){
	$tle = Addslashes($_POST['stt']);
	$sql = "select * from `write` where title like '%{$tle}%'";}
	if($_GET['act']=='sct'){
	$con = Addslashes($_POST['sct']);
	$sql = "select * from `write` where content like '%{$con}%'";}
}
$res=$mysqli->query($sql);
$id= 0;
foreach($res as $var){
	$id=$id + 1;
	echo '<div class="city">';
	echo '<p>第'.$id.'篇<br>标题：'.$var['title'].'<br>作者：'.$var['author'].'<br>时间：'.$var['time'];
    echo '<hr/><a href="./skim.php?id='.$var['id'].'&page=1">查看</a>';
	//作者有权修改删除自己文章
    if($var['author']==$_SESSION['ath']){ 
		echo '|<a href="./modify.php?id='.$var['id'].'">修改</a>|<a href="./deleteone.php?id=wz'.$var['id'].'">删除</a>';
	}
	echo '</p></div>';
}
if($id==0){
echo '<div id="body"><h2>搜索结果为空</h2></div>';	
}
?>

<div id="foot"><h2>
<a href="../html/select.html">返回搜索</a></h2></div>
</body>
</html>